# @Author   : 懒羊羊
# @File     : address.py
# @Time     : 2024/12/4 20:36
import time

from selenium.webdriver.chrome import webdriver
from selenium.webdriver.common.by import By

from loginpage import login

wd = webdriver.WebDriver()
wd.implicitly_wait(10)
login(wd, 'lbxx', '123456')

wd.find_element(By.PARTIAL_LINK_TEXT, "收货地址").click()

# 点击省下拉框
a = wd.find_element(By.CSS_SELECTOR, "select[name='province']")
a.click()

# 选择省份
b = a.find_element(By.XPATH, "//*[@id='selProvinces_0']/option[2]")
b.click()

# 点击市下拉框
c = wd.find_element(By.CSS_SELECTOR, "select[name='city']")
c.click()

# 选择市
d = c.find_element(By.XPATH, '//*[@id="selCities_0"]/option[2]')
d.click()

# 点击县下拉框
e = wd.find_element(By.CSS_SELECTOR, "select[name='district']")
e.click()

# 选择县
f = c.find_element(By.XPATH, '//*[@id="selDistricts_0"]/option[2]')
f.click()

# 输入收货人姓名
e = wd.find_element(By.CSS_SELECTOR, "input[name='consignee']")
e.send_keys("蜡笔小新")

# 输入详细地址
e = wd.find_element(By.CSS_SELECTOR, "input[name='address']")
e.send_keys("北京")

# 输入电话
e = wd.find_element(By.CSS_SELECTOR, "input[name='tel']")
e.send_keys("18888888888")

# 点击新增收货地址
e = wd.find_element(By.CSS_SELECTOR, "input[name='submit']")
e.click()
